#include <iostream>
#include <algorithm>

using namespace std;

// 返回10的i长度次方
int getc(int i)
{
    int ret = 1;
    while (ret < i) ret *= 10;
    return ret;
}

int main(int argc, char const *argv[])
{
    long long result,nmax, temp, datas[24];
    int n, i;

    cin >> n;

    for (i = 0; i < n; i++) cin >> datas[i];

    nmax = 0;
    sort(datas, datas + n);
    do
    {
        temp = datas[0];
        for (i = 1; i < n; i++)
        {
            temp *= getc(datas[i]);
            temp += datas[i];
        }
        nmax = max(nmax, temp);
    } while (next_permutation(datas, datas + n));

    cout << nmax;

    return 0;
}
